/*
 * Copyright 2010 original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.alertleon;

public class AlertConfigurationBuilder {

    private static final int DEFAULT_DELAY = 1;
    private static final int DEFAULT_PORT = 25;

    private boolean enabled;
    private int delay;
    private int port;
    private String smtpServer;
    private String fromAddress;
    private String toAddress;
    private String subject;
    private String excludeClasses;

    public boolean enabled() {
        return enabled;
    }

    public AlertConfigurationBuilder enabled(boolean enabled) {
        this.enabled = enabled;
        return this;
    }
    
    public int delay() {
        if (delay <= 0) {
            delay = DEFAULT_DELAY;
        }

        return delay;
    }

    public AlertConfigurationBuilder delay(int delay) {
        this.delay = delay;
        return this;
    }

    public int port() {
        if (port <= 0) {
            port = DEFAULT_PORT;
        }

        return port;
    }

    public AlertConfigurationBuilder port(int port) {
        this.port = port;
        return this;
    }

    public String fromAddress() {
        return fromAddress;
    }

    public AlertConfigurationBuilder fromAddress(String fromAddress) {
        this.fromAddress = fromAddress;
        return this;
    }

    public String smtpServer() {
        return smtpServer;
    }

    public AlertConfigurationBuilder smtpServer(String smtpServer) {
        this.smtpServer = smtpServer;
        return this;
    }

    public String subject() {
        return subject;
    }

    public AlertConfigurationBuilder subject(String subject) {
        this.subject = subject;
        return this;
    }

    public String toAddress() {
        return toAddress;
    }

    public AlertConfigurationBuilder toAddress(String toAddress) {
        this.toAddress = toAddress;
        return this;
    }

    public String excludeClasses() {
        return excludeClasses;
    }

    public AlertConfigurationBuilder excludeClasses(String excludeClasses) {
        this.excludeClasses = excludeClasses;
        return this;
    }

    public AlertConfiguration build() {
        return new AlertConfiguration(this);
    }
}
